#include <stdio.h>
#define NUM 30
int main(void)
{
	int players[NUM];
	int out = 0, j = 0, k = 0;
	for (int i = 0; i < NUM; i++) players[i] = 1;
	while (1){	
		if(j==NUM)
		j=0;
		if(players[j]==1){
			k++;
			if(k%3==0){ 
				players[j]=0;
				out++;
				printf("第%d个出局的是%d号同学\n",out,j+1);
			} 
		}
		j++;
		if(out==NUM-1)break;
	}
	for (int l = 0; l < NUM; l++)if (players[l] == 1)printf("\n最后剩下的是第%d位同学\n", l+1);
	system("pause");
	return 0;
}
